﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using OpenWaves.Web.Controls;
using OpenWaves.EPiServer;
using OpenWaves.Navigation;
using OpenWaves.Navigation.EPiServer;
using EPiServer.Core;
using OpenWaves.Navigation.Controls;
using EPiServer;

namespace $rootnamespace$.Controls
{
	public partial class MegaMenu : UserControlBase
    {
        protected override void OnLoad(EventArgs e)
        {
            this.DataBind();

			//
			// Remove the section below if you include client side assets in a master page
			//
            this.Page.Header.Controls.Add(new StylesheetLink("/Content/Styles/mega-menu.css"));
            this.Page.ClientScript.RegisterClientScriptInclude(typeof(MegaMenu), "mega-menu", "/Content/Scripts/mega-menu.js");
            this.Page.ClientScript.RegisterStartupScript(typeof(MegaMenu), "mega-menu-init", "$('.mega-menu').megaMenu();", true);
        }

        protected INavigationViewModel<NavigationNode> CreateModel()
        {
            return new EPiNavigationViewModel<NavigationNode>(
				PageReference.StartPage.GetChildren().Select(p=>new MegaMenuNode(p)), 
				this.CurrentPage);
        }
    }
}